<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:output method="html" encoding="UTF-8" indent="yes"/>

	<xsl:variable name="version">0.5</xsl:variable>
	<xsl:variable name="url" select="jolidoc/url"/>

	<xsl:template match="jolidoc">
		<html>
			<head>
				<title><xsl:value-of select="title"/></title>
				<link rel="stylesheet" type="text/css" href="../structure/css-jolidoc.css" />
			</head>
			<body>
				<div id="serviceTitle">
				<h1><xsl:value-of select="title"/></h1>
				<div id="descriptionService"><xsl:value-of select="description"/></div>
				</div>
				<div id="functionList">
				<xsl:for-each select="function">
				
				<xsl:sort select="name" order="ascending" lang="FR" data-type="text"/>

				<table class="function">
					<tr>
						<td class="function" colspan="3">
							<span class="type"><xsl:value-of select="returns/@type"/></span>
							          <xsl:text disable-output-escaping="yes"> </xsl:text>
							<span class="function"><xsl:value-of select="name"/></span>
							(<xsl:apply-templates mode="signature" select="param"/>)
						</td>
					</tr>
					<tr>
                                                <td height="10px" class="url" colspan="3"><xsl:value-of select="$url"/>/<xsl:value-of select="name"/></td>
					</tr>
					<tr>
						<td height="10px" class="goal" colspan="3"><xsl:value-of select="goal"/></td>
					</tr>

					 <xsl:if test="./param">

					<tr>
						<td class="separator" colspan="3">Paramètres</td>
					</tr>
					<tr>
						<th>
							Type
						</th>
						<th>
							Paramètre
						</th>
						<th>
							Détails
						</th>
					</tr>
					
					<xsl:apply-templates mode="detail" select="param"/>
					</xsl:if>


					<xsl:if test="returns/return">
						<tr>
							<td class="separator" colspan="3">Retour (<span class="type"><i><xsl:value-of select="returns/@type"/></i></span>)</td>
						</tr>
						<xsl:apply-templates mode="detail" select="returns"/>
					</xsl:if>
				</table>

				</xsl:for-each>
				</div>
				
				<div id="copyright">
					<p class="version">
						Propulsé par Jolidoc <xsl:value-of select="$version"/>
					</p>
					<p class="project">
						<xsl:value-of select="copyright"/>
					</p>
				</div>
			</body>
		</html>
	</xsl:template>
	
	
	<!-- Signature -->
	<xsl:template mode="signature" match="param">
		<span class="type"><xsl:value-of select="type"/></span>
		<xsl:text disable-output-escaping="yes"> </xsl:text>
		<span class="name"><xsl:value-of select="name"/>
		<xsl:if test="@multiplicity = 'many'">+</xsl:if>
		<xsl:if test="@multiplicity = 'many-implied'">*</xsl:if>
		<xsl:if test="@multiplicity = 'one-implied'">?</xsl:if>
		</span>
		<xsl:if test="position() != last()">
		,
		</xsl:if>
	</xsl:template>
	
	
	
	
	<!-- Parametre details -->
	<xsl:template mode="detail" match="param">
	<tr>
		<td class="resume">
			<span class="type"><xsl:value-of select="type"/></span>
		</td>
		<td class="resume">
			<xsl:text disable-output-escaping="yes"> </xsl:text>
			<span class="name"><xsl:value-of select="name"/>
			<xsl:if test="@multiplicity = 'many'">+</xsl:if>
			<xsl:if test="@multiplicity = 'many-implied'">*</xsl:if>
			<xsl:if test="@multiplicity = 'one-implied'">?</xsl:if>
			</span>
		</td>
		<td class="details"><xsl:value-of select="value"/></td>
		
	</tr>
	</xsl:template>
	
	
	
	<!-- Retour -->
	<xsl:template mode="detail" match="returns">
		<tr>
			<th>
				Valeur
			</th>
			<th colspan="2">
				Détails
			</th>
		</tr>
		<xsl:apply-templates mode="detail" select="return"/>
	</xsl:template>

	<xsl:template mode="detail" match="return">
	<tr>
		<td class="resume"><xsl:value-of select="value"/></td>
		<td class="details" colspan="2"><xsl:value-of select="result"/></td>
	</tr>
	</xsl:template>

</xsl:stylesheet>
